package jxc.data.hibernate.dao;

import java.util.List;

import org.hibernate.Query;

import jxc.data.hibernate.pojo.Sales;

public class SalesDAO extends HibernateBaseDAO<Sales> {

	public List<Sales> getAll() {
		return this.listByHQL("from Sales");
	}

	public long countGoods(String gid){
		String hql="select sum(number) from Sales where tbGoods.id=:id";
		Query query=session.createQuery(hql);
		query.setString("id", gid);
		Long number=(Long)query.uniqueResult();
		if(number==null)
			return 0;
		return number;
	}
}
